package org.emet.dao;

import org.emet.jee.console.entity.sys.DataDic;
import org.emet.jee.core.dao.Page;
import org.emet.jee.core.dao.arch.ArchDataSourceBaseDao;
import org.emet.service.dto.DataDicCriteria;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

@Repository
public class DataDicDao extends ArchDataSourceBaseDao<DataDic, Long> {
	public Page<DataDic> search(Page<DataDic> page, DataDicCriteria criteria) {
		Criteria c = getSession().createCriteria(DataDic.class);
		NonEmptyValueHashMap<String, Object> propertyNameValues = new NonEmptyValueHashMap<String, Object>();
		propertyNameValues.put("name", criteria.getName());
		propertyNameValues.put("description", criteria.getDescription());
		c.add(Restrictions.allEq(propertyNameValues));
		page.setOrderBy("id");
		page.setOrder("asc");
		return findPage(page, c);
	}
}
